import { ElLoading } from 'element-plus';
import { nextTick } from 'vue';
let loadingCount = 0;
let loading: any;
const startLoading = () => {
	loading = ElLoading.service({
		lock: true,
		text: '加载中……',
		background: 'rgba(0, 0, 0, 0.7)',
	});
};
const endLoading = () => {
	nextTick(() => {
		loading.close();
	});
};
export const showLoading = () => {
	if (loadingCount === 0) {
		startLoading();
	}
	loadingCount += 1;
};
export const hideLoading = () => {
	if (loadingCount <= 0) {
		return;
	}
	loadingCount -= 1;
	if (loadingCount === 0) {
		endLoading();
	}
};
